<template>
  <el-button
    :size="size"
    :type="type"
    :icon="icon"
    :loading="loading"
    v-show="hasPerms(perms)"
  >
    {{ label }}
  </el-button>
</template>
<script>
import { hasPermission } from "../utils/permission";

export default {
  name: "TsButton",
  props: {
    //显示文本
    label: {
      type: String,
      default: "",
    },
    type: {
      type: String,
      default: null,
    },
    //  按钮显示图标
    icon: {
      type: String,
      default: "",
    },
    //按钮尺寸
    size: {
      type: String,
      default: "small",
    },
    //按钮加载标识
    loading: {
      type: Boolean,
      default: false,
    },
    //  按钮是否禁用
    disabled: {
      type: Boolean,
      default: false,
    },
    //  按钮权限标识
    perms: {
      type: String,
      default: null,
    },
  },
  methods: {
    hasPerms: function (perms) {
      return hasPermission(perms); //& !this.disabled
    },
  },
};
</script>

<style scoped></style>
